<template>
  <div class="set-advice-detail">
    <w-nav-bar
      title="意见详情"/>
    <group>
      <cell
        title="姓名、昵称"
        :value="model.name"/>
    </group>
    <group>
      <cell
        title="发布时间"
        :value="model.dateStr"/>
    </group>
    <group v-if="model.phone">
      <cell
        title="手机号"
        :value="model.phone"/>
    </group>
    <group v-if="model.qq">
      <cell
        title="QQ"
        :value="model.qq"/>
    </group>
    <group v-if="model.wx">
      <cell
        title="微信"
        :value="model.wx"/>
    </group>

    <group title="意见、建议">
      <cell
        :title="model.content"/>
    </group>
    <group>
      <x-switch
        title="是否显示到意见列表"
        @on-click="switchChange"
        prevent-default
        v-model="model.isShow"/>
    </group>
    <div class="w-max-btn w-btn-fixed-b">
      <x-button
        type="warn"
        @click.native="removeBtnClick">删除</x-button>
    </div>
  </div>
</template>

<script>
  import FeedBackModel from '@/models/web/FeedBackModel'
  import { XSwitch, XButton, Group, Cell } from 'vux'

  export default {
    name: 'SetAdviceDetail',
    components: {
      XSwitch,
      XButton,
      Group,
      Cell
    },
    data() {
      return {
        model: new FeedBackModel()
      }
    },
    mounted() {
      this.getDetail()
    },
    methods: {
      /**
       * 获取详情数据
       */
      getDetail() {
        this.model._id = this.$route.query.id
        this.model.getDetail().w_then()
      },
      /**
       * 是否显示开关改变调用
       */
      switchChange() {
        this.model.isShow = !this.model.isShow
        this.model.addOrUpdate().w_then()
      },
      /**
       * 删除按钮点击
       */
      removeBtnClick() {
        this.model.dustbin_push('name').w_then(() => {
          this.$w_popview.msgSuccess('删除成功', {
            onClose: () => {
              this.$router.go (-1)
            }
          })
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .set-advice-detail {
  }
</style>
